//
//  TTHomeVcMod.swift
//  TTWeibo
//
//  Created by 陶宏路 on 16/7/23.
//  Copyright © 2016年 陶路路. All rights reserved.
//

import UIKit

class TTHomeVcMod: NSObject {
    
    /// 创建时间
    var created_at: String?
    /// 微博ID
    var id: Int64 = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    //  用户数据
    var user: TTHomeViewModel?
    
    // 转发数
    var reposts_count: Int = 0
    // 评论数
    var comments_count: Int = 0
    // 表态数
    var attitudes_count: Int = 0
    
    var retweeted_status:TTHomeVcMod?
    
    var pic_urls:[TTPictureModel]?

    init(dict:[String:AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user"{
            
            guard let v = value as? [String : AnyObject] else{
                
                return
            }
            
            user = TTHomeViewModel.init(dict: v)
            
        }else if key == "retweeted_status"{
            
            guard let re = value as? [String:AnyObject] else{
                
                return
            }
            
            retweeted_status = TTHomeVcMod.init(dict: re)
            
        }else if key == "pic_urls"{
            
            var tempArray:[TTPictureModel] = [TTPictureModel]()
            
            guard let va = value as? [[String:AnyObject]] else{
                
                return
            }
            
            for dict in va {
                
                let model:TTPictureModel = TTPictureModel(dict: dict)
                
                tempArray.append(model)
            }
            
            pic_urls = tempArray
            
        }else{
        
        super.setValue(value, forKey: key)
            
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
}
